package com.example.springblog.service;

import com.example.springblog.mapper.BlogMapper;
import com.example.springblog.model.BlogInfo;
import com.example.springblog.model.BlogList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class BlogService {
    @Autowired
    private BlogMapper blogMapper;
    public List<BlogList> getList(){
       return blogMapper.selectAll();
    }

    public BlogInfo getBlogDetail(Integer blogId) {
        return blogMapper.selectById(blogId);
    }

    public Boolean insertBlog(BlogInfo blogInfo) {
        Integer i = blogMapper.insertBlog(blogInfo);
        if(i>0){
            return true;
        }else {
            return false;
        }
    }

    public Integer update(BlogInfo blogInfo) {
        return blogMapper.updateBlog(blogInfo);

    }
}
